package likou.bit_manipulation;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author: 唐小尊
 * @email: 1171702529@qq.com
 * @cate: 2021/05/12 09:03
 */
public class _187 {
    public List<String> findRepeatedDnaSequences(String s) {
        Map<String,Integer> map = new HashMap<>();
        List<String> lists = new ArrayList<>();
        for(int i=0;i<s.length()-10;i++){
            String key = s.substring(i, i + 10);
            if (map.get(key)<2){
                Integer value = map.getOrDefault(key, 0);
                map.put(key,value+1);
                if (value+1==2){
                    lists.add(key);
                }
            }
        }
        return lists;
    }
}
